package com.paireach.szwolaiyun.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.paireach.szwolaiyun.R;
import com.paireach.szwolaiyun.mode.GoodsMode;

/**
 * Created by Administrator on 2016/6/23.
 */
public class WaybillDetailsAdapter extends BaseAdapter {
    private Context context;
    private GoodsMode goodsMode;

    public WaybillDetailsAdapter( Context context,GoodsMode goodsMode){
        this.context=context;
        this.goodsMode=goodsMode;
    }
    public int getCount() {
        return goodsMode.getList().size();
    }

    @Override
    public Object getItem(int position) {
        return goodsMode.getList().get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Mode mode=null;
        if(convertView==null){
            mode=new Mode();
            convertView= LayoutInflater.from(context).inflate(R.layout.goodsdateil_item,null);

            mode.tv_plancount=(TextView)convertView.findViewById(R.id.tv_plancount);
            mode.tv_product_code=(TextView)convertView.findViewById(R.id.tv_product_code);
            mode.tv_product_name=(TextView)convertView.findViewById(R.id.tv_product_name);
            convertView.setTag(mode);
        }else{
            mode= (Mode) convertView.getTag();
        }
        mode.tv_product_code.setText(goodsMode.getList().get(position).getCode());
        mode.tv_product_name.setText(goodsMode.getList().get(position).getName());
        mode.tv_plancount.setText(goodsMode.getList().get(position).getNum());
        return convertView;
    }

    private class Mode{
        private TextView tv_product_code;
        private TextView tv_product_name;
        private TextView tv_plancount;
    }
}
